import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue';
import UserListView from '../views/UserListView';
import UserProfileView from '../views/UserProfileView';
import LoginView from '../views/LoginView';
import RegisterView from '../views/RegisterView';
import NotFoundView from '../views/NotFoundView';

const routes = [
  {
    path: '/myspace/',
    name: 'HomeView',
    component: HomeView
  },
  {
    path: '/myspace/userlist/',
    name: 'UserListView',
    component: UserListView
  },
  {
    path: '/myspace/userprofile/:userId/', // :表示后面接的是参数
    name: 'UserProfileView',
    component: UserProfileView
  },
  {
    path: '/myspace/login/',
    name: 'LoginView',
    component: LoginView
  },
  {
    path: '/myspace/register/',
    name: 'RegisterView',
    component: RegisterView
  },
  {
    path: '/myspace/NotFound/',
    name: 'NotFoundView',
    component: NotFoundView
  },
  {
    path:'/myspace/:catchAll(.*)',//catchAll表示正则表达式,
    component: NotFoundView
  },
  {
    path: "/community",
    name: "community",
    component: CommunityViews,
    meta: {
      title: "社区主页"
    }
  },
  {
    path: "/community/create",
    name: "community_create",
    component: CreateCommunityViews,
    meta: {
      title: "创建社区"
    }
  },
  {
    path: "/community/detail/communityId=:communityId",
    name: "community_detail",
    component: CommunityDetailViews,
    meta: {
      title: "社区详情"
    }
  },
  {
    path: "/community/publish/article/communityId=:communityId",
    name: "publish_community_article",
    component: PublishCommunityArticle,
    meta: {
      title: "发布社区文章"
    }
  },
  {
    path: "/community/article/communityId=:communityId/communityArticleId=:communityArticleId",
    name: "community_article",
    component: CommunityArticleViews,
    meta: {
      title: "社区文章详情",
      isExistArticle: true,
    },
  },
  {
    path: "/community/article/edit/:communityId/:communityArticleId",
    name: "community_article_edit",
    component: CommunityArticleEdit,
    meta: {
      title: "社区文章编辑页面",
    }
  },
  {
    path: "/community/rank",
    name: "community_rank",
    component: CommunityRankViews,
    meta: {
      title: "社区排行"
    }
  },
  {
    path: "/community/manage/:communityId",
    name: "community_manage",
    component: ManageViews,
    meta: {
      title: "社区管理",
      // 授权
      isAuthorization: true,
    },
    children: [
    {
      path: "userManage",
      name: "manage_user",
      component: UserManage,
      meta: {
        title: "用户管理",
        isAuthorization: true,
      }
      },
      {
        path: "roleManage",
        name: "role_manage",
        component: RoleManage,
        meta: {
          title: "角色管理",
          isAuthorization: true,
        }
      },
      {
        path: "userApplication",
        name: "user_application",
        component: AddApplication,
        meta: {
          title: "加入申请",
          isAuthorization: true,
        }
      },
      {
        path: "contentManage",
        name: "content_manage",
        component: ContentManageViews,
        meta: {
          title: "内容管理",
          isAuthorization: true,
        }
      },
      {
        path: "channelManage",
        name: "channel_manage",
        component: ChannelManage,
        meta: {
          title: "频道管理",
          isAuthorization: true,
        }
      },
      {
        path: "informationManage",
        name: "information_manage",
        component: CommunityInfoManage,
        meta: {
          title: "信息管理",
          isAuthorization: true,
        }
      },
    {
      path: "administratorConfig",
      name: "administrator_config",
      component: AdminConfig,
      meta: {
        title: "管理员配置",
        isAuthorization: true,
      }
    }
  ]
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
